<?php

use App\Enums\OpenShop\InvestmentPromotion\SiteLocationEnum;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class AlterTableSiteLocationAddColumns extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('open_shop_site_locations', function (Blueprint $table) {
            $table->string('handleBusinessLicense', 2)->default("")
                  ->comment(enumToMigrationComment(SiteLocationEnum::HANDLE_BUSINESS_LICENSE_MAP, "是否可办理营业执照"))
                  ->after("otherFee");
            $table->text('handleBusinessLicenseNoReason')->default("")->comment("不能办理营业执照原因")
                  ->after("handleBusinessLicense");
            $table->string('historyBusinessLicense', 2)->default("")
                  ->comment(enumToMigrationComment(SiteLocationEnum::HISTORY_BUSINESS_LICENSE_MAP, "历史营业执照照片"))
                  ->after("handleBusinessLicenseNoReason");
            $table->text('historyBusinessLicenseNoReason')->default("")->comment("没有历史营业执照原因")
                  ->after("historyBusinessLicense");

            $table->string('handleFoodLicense', 2)->default("")
                  ->comment(enumToMigrationComment(SiteLocationEnum::HANDLE_FOOD_LICENSE_MAP, "是否可办理食品安全许可证"))
                  ->after("historyBusinessLicenseNoReason");
            $table->text('handleFoodLicenseNoReason')->default("")->comment("不能办理食品安全许可证原因")
                  ->after("handleFoodLicense");
            $table->string('historyFoodLicense', 2)->default("")
                  ->comment(enumToMigrationComment(SiteLocationEnum::HISTORY_FOOD_LICENSE_MAP, "历史食品安全许可证照片"))
                  ->after("handleFoodLicenseNoReason");
            $table->text('historyFoodLicenseNoReason')->default("")->comment("没有历史食品安全许可证原因")
                  ->after("historyFoodLicense");

            $table->text('licenseRemark')->default("")->comment("办证模块备注说明")->after("historyFoodLicenseNoReason");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('open_shop_site_locations', function (Blueprint $table) {
            $table->dropColumn('handleBusinessLicense');
            $table->dropColumn('handleBusinessLicenseNoReason');
            $table->dropColumn('historyBusinessLicense');
            $table->dropColumn('historyBusinessLicenseNoReason');

            $table->dropColumn('handleFoodLicense');
            $table->dropColumn('handleFoodLicenseNoReason');
            $table->dropColumn('historyFoodLicense');
            $table->dropColumn('historyFoodLicenseNoReason');

            $table->dropColumn('licenseRemark');
        });
    }
}
